package exceptions;

/**
 * This Exception should be thrown when a positive number was expected, but
 * the actual number was zero or negative.
 * 
 * @author Shimu
 * @date 8-May-2013
 */
public class NegativeNumberOrZeroException extends Exception {
   
    public NegativeNumberOrZeroException(String name, int num) {
        super(String.format("%s should be positive, but was %d instead", name, num));
    }
    
    public static void validate(String name, int num) 
            throws NegativeNumberOrZeroException {
        if (num < 1) {
            throw new NegativeNumberOrZeroException(name, num);
        }
    }
}
